package com.ibm.dtp.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;

import javax.jws.WebService;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;


import com.ibm.dtp.base.ws.EventRequest;
import com.ibm.dtp.base.ws.EventResponse;
import com.ibm.dtp.base.ws.vo.EPC;
import com.ibm.dtp.base.ws.vo.Event;
import com.ibm.dtp.base.ws.vo.EventVO;
import com.ibm.dtp.base.ws.vo.Transaction;
import com.ibm.dtp.service.iface.DtpWSServiceIF;

@WebService(name="DtpWSService", targetNamespace="http://impl.service.dtp.ibm.com/", serviceName="DtpWSServiceService", portName="DtpWSServicePort")
public class DtpWSService implements DtpWSServiceIF{

	@Override
	@WebMethod(operationName = "searchEvent", action = "")
    @WebResult(targetNamespace = "")
    @RequestWrapper(localName = "searchEvent", targetNamespace = "http://impl.service.dtp.ibm.com/")
    @ResponseWrapper(localName = "searchEventResponse", targetNamespace = "http://impl.service.dtp.ibm.com/")
	public EventResponse searchEvent(@WebParam(name = "eventRequest", targetNamespace = "")EventRequest request) {
		EventResponse result =new EventResponse();
		result.setLangCD("ja");
		result.setSearchMode("5");
		result.setCurrentTime(new Date());
		result.setErrorCD("0");
		result.setErrorMessage("no message");
		List<EventVO> eventList = new ArrayList<EventVO>();
		Event e1 = new Event();
		e1.setEventType("ObjectEvent");
		e1.setEventTime("2010-08-01-10.00.00.000000");
		e1.setRecordTime("2010-08-01-10.00.00.000000");
		e1.setAction("OBSERVE");
		List<EPC> epcList = new ArrayList<EPC>();
		EPC epc1 = new EPC();
		epc1.setEpc("urn:ibm:dtp:id:sgtin:4912345.100999.1101");
		epcList.add(epc1);
		e1.setEPCList(epcList);
		e1.setBusinessStep("urn:ibm:dtp:bizstep:shipping");
		e1.setBusinessLocation("urn:ibm:dtp:loc:4912345.302014");
		e1.setReadPoint("reader1");
		e1.setDisposition("urn:ibm:dtp:disp:active");
		List<Transaction> transactionList =new ArrayList<Transaction>();
		Transaction t = new Transaction();
		t.setTransactionID("1234567890");
		t.setTransactionType("Sales");
		e1.setTransactionList(transactionList);
		e1.setParentID("");
		e1.setProductName("目鯛");
		e1.setLocationName("xxx漁港");
		e1.setAddress1("北海道abcd市yyy海岸1-3-2");
		e1.setAddress2("zzz埠頭506");
		e1.setPostCode("100-000");
		e1.setPhoneNumber("010-1234-5678");
		e1.setAreaName("北日本");
		e1.setCountryName("日本");
		e1.setExtensionXML("<temperatureList><temperature>-19.00<" +
				"/temperature><temperature>-18.90</temperature><" +
				"temperature>-18.45</temperature></temperatureList>");
		e1.setEventTimeZoneOffset("900");
		EventVO ev = new EventVO();
		ev.setEvent(e1);
		eventList.add(ev);
		result.setEventList(eventList);
		return result;
	}

}
